/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package zilvic.game.character.inventory;

import zilvic.resources.ByteMagic;

/**
 *
 * @author Erik
 */
public class Inventory {
    private int totalArmor;
    private int weaponDamage;
    private double totalWeight;
    private Item[] inventoryList;

    public Inventory(int slotCount) {
        inventoryList = new Item[slotCount];
    }
    public int getTotalItemArmor(){
        for (int i = 0; i < inventoryList.length; i++) {
            if (inventoryList[i].isEquiped() == true){
                totalArmor = totalArmor + inventoryList[i].getArmorValue();
            }
        }
        return totalArmor;
    }
    //returns the ArmorValue of all items that are currently equiped

    public void equip(int id){
        if (inventoryList[id].isEquiped() == false){
        }
    }
    //is going to make an item equiped

    public int getTotalWeaponDamage(){
        for (int i = 0; i < inventoryList.length; i++) {
            if (inventoryList[i].isEquiped() == true){
                weaponDamage = weaponDamage + inventoryList[i].getDamageValue();
            }
        }
        return weaponDamage;
    }
    //returns the DamageValue of all items that are currently equiped

    public double getTotalWeight(){
        for (int i = 0; i < inventoryList.length; i++) {
            totalWeight = totalWeight + inventoryList[i].getWeight();
        }
        return totalWeight;
    }
    //returns the totalweight of all items in your inventory

    public String getName(int i){
        return inventoryList[i].getName();
    }
    //Returns the name of the times you ask for

    public byte[] toBytes (){
        return ByteMagic.compressBytes(new byte[][] {
            ByteMagic.parsablesToBytes(inventoryList)});
    }
    //Saves your inventory in bytes

    public void fromBytes(byte[] bytes) {
        byte[][] u = ByteMagic.uncompressBytes(bytes);
        inventoryList = (Item[]) ByteMagic.bytesToParsables(u[0]);
    }
    //Loads your inventory from bytes
}
//TODO: Move the "equiped" variable to Inventory from Item